<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" name="username" placeholder="请输入用户名">
<input type="password" name="password" placeholder="请输入密码">
<button type="button" onclick="reg()">提交</button>
</body>
<script>
    function reg () {
       var username = document.getElementsByName("username");
    }
</script>
</html>